/**
 * Created by liubin on 2017/6/14.
 */


var DdzRoundEndedEventddz = function(){
    var that = new GameResponseBase();

    that.handle = function (binary, msgid) {
        that.loadMessage(binary, msgid);

        that.handleMsg(that.msg);
    };

    that.handleMsg = function(msg){
        that.msg = msg;

        //记录打了多少盘
        mo.ddzTable.mPlayGameCount++;

        //是否是断线重练收到的
        if (mo.ddzTableStatus.isReconnect){
            //结算界面
            mo.ddzTable.mDdzTableUILayer.mDdzTableEndLayer.setEndInfo(that.msg, 0);
        }else{
            //ui动画
            var hosetSeat = 0;
            var scores = [];
            var handCards = [];
            for (var seat = 0; seat < 4; seat++){
                var logicSeat = mo.ddzTableStatus.getLogicForView(seat, that.msg.MySeat - 1);
                var seatUser = that.msg["SeatUser" + (logicSeat + 1)];

                if (seatUser != null){
                    if (seatUser.IsHost){
                        hosetSeat = seat;
                    }

                    var allfen = 0;
                    var ids = seatUser.LostWin.ItemTypes;
                    var nums = seatUser.LostWin.ItemNums;
                    allfen = mo.gameUserInfo.getItemNum(ids, nums, 0);
                    scores.push(allfen);

                    handCards.push(seatUser.HandCards);
                }else{
                    scores.push(-9999);
                    handCards.push([]);
                }
            }

            var delayTime = mo.ddzTable.openAllPlayerCards(handCards, scores, hosetSeat);

            delayTime += 3;

            //结算界面
            mo.ddzTable.mDdzTableUILayer.mDdzTableEndLayer.setEndInfo(that.msg, delayTime);
        }

    };

    return that;
};